package com.aaa.controller;
import com.aaa.service.L_CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/koufen")
public class L_CategoryController {

    @Autowired
    private L_CategoryService service;

    @RequestMapping("/tiaozhuan")
    public String yemian() {
        return "Declarationmanagement/Categorymanagement";
    }


    @RequestMapping("/list")
    @ResponseBody
    public Object list(@RequestBody Map map) {
        List<Map> list = service.getAll(map);
        System.out.println(map.get("pageSize"));
        Integer total = service.getCount(map);
        System.out.println(map.get("start"));
        Map maps = new HashMap();
        maps.put("data", list);
        maps.put("total", total);
        return maps;
    }

    //通过审核的方法
    @RequestMapping("/shenhe")
    @ResponseBody
    public String shenhe(@RequestBody Map map){
        Date time=new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String endtime = sdf.format(time);
        map.put("endtime",endtime);
        //获取审核人
        S_LoginController login=new S_LoginController();
        String name=login.name();
        System.out.println(name+"   +++++++");
        map.put("user",name);
        service.on(map);
        return "redirect:tiaozhuan";
    }

    @RequestMapping("/delete")
    @ResponseBody
    public String delete(@RequestBody Map map){
        service.delete(map);
        return "redirect:tiaozhuan";
    }
}